using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DocManager
{
    public class DBPub
    {
        static IDBAgent _IDBAgent = null;
        public static IDBAgent DBAgent
        {
            get
            {
                if (_IDBAgent==null)
                    _IDBAgent = ClsDBAccess.CreateDBAgent();
                return _IDBAgent;
            }
        }

        public static int GetID(string tableName)
        {
            string sql = string.Format("select max(id) from {0}", tableName);
            DataTable dt = DBAgent.ExeQuery(sql);
            if (dt.Rows.Count > 0)
            {
                string idStr = dt.Rows[0][0].ToString();
                if (string.IsNullOrEmpty(idStr))
                    return 0;
                else
                    return int.Parse(idStr) + 1;
            }
            return 0;
        }

        public static string CurrentUser;

        public static string rightStr;
    }
}
